package com.demo.advice;

import com.demo.model.User;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Auther: luobiao
 * @Date: 2020/5/28 06:33
 * @Description:
 */
@ControllerAdvice
public class MyAdvice {

    //在Advice中配置的ModelAttribute优先级比Controller中配置的要高
    @ModelAttribute
    public User modelAttributeUser(){
        User user=new User();
        //Advice中中设置性别默认值为0表是是女
        user.setSex("woman");
        return user;
    }
}
